//所有请求
import { request } from "../axios/index";
import axios from "../axios/index";
// 拼接查询参数
const dataToPramas = (data) => Object.entries(data).map(item => item.join("=")).join("&")
/**
 * 获取当前所在城市
 */

export const currentcity = (number) => axios.get('/v1/cities/' + number);

// 搜索地址
export const searchKey = (data) => axios.get('/v1/pois'+dataToPramas(data))
//elm.cangdu.org/v1/pois?city_id=1&keyword=迪士尼&type=search 
export const searchplace = (cityid, value) => axios.get('/v1/pois?city_id='+cityid+'&keyword='+value+'&type=search');
//所有商铺列表，首页下面的店铺
export const getFoodShops = (data) => axios.get("shopping/restaurants?" + dataToPramas(data))
//商铺信息
export const getShopInfo = (id) => axios.get("/shopping/restaurant/" + id)
//商品信息
export const getFoodList = (id) => axios.get("/shopping/v2/menu?restaurant_id="+id)
// 搜索商铺
export const SearchShopList = (abc) => axios.get("https://elm.cangdu.org/v4/restaurants?geohash=31.22967,121.4762&keyword=a"+abc)
// export function getShopInfo(id) {
//     return request({
//         url: "/shopping/restaurant/" + id
//     })
// }

// 获取用户地址
export const getAddress = (user_id) =>axios.get({
    methods:"get",
    url:'/v1/users/' + user_id + '/addresses',
    params:{
        user_id,
    }
}) 

//食品分类列表
export const foodlist = () => axios.get('v2/index_entry')

// 请求商铺分类列表
export const getCategoryList = (data) => axios.get('/shopping/v2/restaurant/category?' + dataToPramas(data))
//获取评论  
export const getCommentInfo =(data)=>axios.get( '/ugc/v2/restaurants/'+data+'/ratings?'+ 'offset=0&limit=10')
// 获取验证码
export const getCaptchas = () => axios.post(`/v1/captchas`)
// mobileLogin登录注册
export const mobileLogin = () => axios.post(`/v2/login`)

// 当前城市 
export const citylist = () => axios.get("/v1/cities?type=guess")
// 请求所有城市
export const citylists = () => axios.get("/v1/cities?type=group")
// 请求所有城市
export const hotcitylist = () => axios.get("/v1/cities?type=hot")
// 请求收货地址列表
export const deliveryAddressList = () => axios.get("/v1/users/74073/addresses")
// 增加收货地址
export const addDeliveryAddress = (data) => axios.post(`/v1/users/${data.user_id}/addresses`, data)
